<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="test"></div>

  <script type="text/javascript" src="../js/react.development.js"></script>
  <script type="text/javascript" src="../js/react-dom.development.js"></script>
  <script type="text/javascript" src="../js/babel.min.js"></script>
  <script type="text/javascript" src="../js/prop-types.js"></script>
  <script type="text/babel">
    class Demo extends React.Component{
        state={isHot:true}
        showData=()=>{
            const {input1} = this
            alert(input1.value)
        }
        changeWeather=()=>{
            const {isHot} = this.state
            this.setState({isHot:!isHot})
        }
        saveInput=(c)=>{
            this.input1 = c
            console.log('@',c);
        }
         render(){
            const {isHot} = this.state
            return(
                <div>
                    <h2>今天天气很{isHot?'炎热':'凉爽'}</h2>
                    {/*<input ref={(currentNode)=>{this.input1=currentNode;console.log('@',currentNode);}} type="text"/><br/>*/}
                    <input ref={this.saveInput} type="text"/>
                    <button onClick={this.showData}>点我提示数据</button>
                    <button onClick={this.changeWeather}>点我切换天气</button>
                </div>
            )
         }
    }
    ReactDOM.render(<Demo/>,document.getElementById('test'))
  </script>
</body>

</html>